package com.fd.dx.sqlprovider;

import com.fd.dx.domain.FW;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * Created by lenovo on 2018/3/10.
 */
public class FWProvider {
    public String getFWInfo(Map<String,String> map){
        String x=map.get("x");
        String y=map.get("y");
        return "SELECT gid,ST_AsEWKT(geom) geom,doorid,doorname\n" +
                "FROM public.fw\n" +
                "WHERE (ST_Within(ST_GeomFromText('POINT("+x+" "+y+")'),geom))";

    }
    public String  updateFWInfo(FW fw){
        return new SQL()
        {{
            UPDATE("public.fw");
            if(fw.getDoorid()!=null)
            {
                SET("doorid=#{doorid}");
            }
            if(fw.getDoorname()!=null)
            {
                SET("doorname=#{doorname}");
            }
            WHERE("gid = #{gid}");
        }}.toString();
    }
}
